﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace UserControlLib.Converters
{
    public class DelayTimeMultiConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values[0] is int index && values[1] is bool isLeftToRight && values[2] is int totalCharacters)
            {
                // 如果是从左到右，则使用正序索引；如果是从右到左，则使用倒序索引
                int adjustedIndex = isLeftToRight ? index : totalCharacters - index - 1;
                return TimeSpan.FromMilliseconds(adjustedIndex * 200); // 每个字符延迟 0.2 秒
            }

            return TimeSpan.Zero;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
